package cn.edu.scau.dropship.ServiceImpl;

import cn.edu.scau.dropship.entity.Order;
import cn.edu.scau.dropship.entity.OrderExample;
import cn.edu.scau.dropship.mapper.OrderMapper;
import cn.edu.scau.dropship.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;

    @Override
    public long countByExample(OrderExample example) {
        return orderMapper.countByExample(example);
    }

    @Override
    public int deleteByExample(OrderExample example) {
        return orderMapper.deleteByExample(example);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return orderMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Order record) {
        return orderMapper.insert(record);
    }

    @Override
    public int insertSelective(Order record) {
        return orderMapper.insertSelective(record);
    }

    @Override
    public List<Order> selectByExample(OrderExample example) {
        return orderMapper.selectByExample(example);
    }

    @Override
    public Order selectByPrimaryKey(Integer id) {
        return orderMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByExampleSelective(Order record, OrderExample example) {
        return orderMapper.updateByExampleSelective(record, example);
    }

    @Override
    public int updateByExample(Order record, OrderExample example) {
        return orderMapper.updateByExample(record, example);
    }

    @Override
    public int updateByPrimaryKeySelective(Order record) {
        return orderMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Order record) {
        return orderMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<Order> selectByUidAndState(Integer uid, String state) {
        OrderExample orderExample=new OrderExample();
        OrderExample.Criteria criteria=orderExample.createCriteria();
        criteria.andBvoIdEqualTo(uid);
        criteria.andStateEqualTo(state);
        List<Order> list=orderMapper.selectByExample(orderExample);
        return list;
    }

    public List<Order> selectToBePaidFromOrder(Integer mvoId)
    {
        return orderMapper.selectToBePaidFromOrder(mvoId);
    }

    public List<Order> selectToBeDeliveredFromOrder(Integer mvoId)
    {
        return orderMapper.selectToBeDeliveredFromOrder(mvoId);
    }

    public List<Order> selectDeliveredFromOrder(Integer mvoId)
    {
        return orderMapper.selectDeliveredFromOrder(mvoId);
    }

    public List<Order> selectFinishedFromOrder(Integer mvoId)
    {
        return orderMapper.selectFinishedFromOrder(mvoId);
    }

    public List<Order> selectCanceledFromOrder(Integer mvoId)
    {
        return orderMapper.selectCanceledFromOrder(mvoId);
    }

    public int updateOrderState(Integer id , String state){
        orderMapper.updateOrderState(id , state );
        return 1;
    }
}
